package pers.corvey.studyjava.service;

import org.springframework.stereotype.Service;

import pers.corvey.studyjava.exception.BadRequestException;
import pers.corvey.studyjava.exception.InternalServerErrorException;
import pers.corvey.studyjava.util.CaptchaUtils;

@Service
public class CaptchaService {

    public void checkCaptcha(String correctCaptcha, String inputCaptcha) {
        if (correctCaptcha == null) {
            throw new InternalServerErrorException("获取验证码错误！请重试！");
        } else if (!CaptchaUtils.checkCaptcha(correctCaptcha, inputCaptcha)) {
            throw new BadRequestException("验证码输入错误！");
        }
    }
    
}
